﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;

namespace VietKinsNutrition.Data
{
    public class ClsTblThamsodauvaoDAL
    {
        public DataTable SelectAll()
        {
            DataTable Tbl = new DataTable();
            string NamePrc = QueryString.TblDm_TblThamsodauvao_Prc;
            OleDbCommand Cmm = new OleDbCommand();
            OleDbDataAdapter Dap;
            Cmm.Connection = ClsConnection.OleDBConnect();
            Cmm.CommandText = NamePrc;
            try
            {
                if (Cmm.Connection.State != ConnectionState.Open) Cmm.Connection.Open(); Cmm.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                Cmm.Connection.Close();
            }
            Dap = new OleDbDataAdapter(Cmm);
            Dap.Fill(Tbl);
            return Tbl;
        }


        public void Insert(bool Baoanchitiet, bool Chitietdiemtruong)
        {
            string NamePrc = QueryString.PRC_TBLTHAMSODAUVAO_INSERT;
            OleDbCommand Cmm = new OleDbCommand();
            Cmm.Parameters.Add(new OleDbParameter("@Baoanchitiet", Baoanchitiet));
            Cmm.Parameters.Add(new OleDbParameter("@Chitietdiemtruong", Chitietdiemtruong));
            ClsConnection.OleDbDAdpter(NamePrc, Cmm);
        }
        public void EditValue2(int Id, bool Baoanchitiet, bool Chitietdiemtruong)
        {
            string NamePrc = QueryString.TBLDM_THANSODAUVAO_VALUE2_EDITPRC;
            OleDbCommand Cmm = new OleDbCommand();
            Cmm.Parameters.Add(new OleDbParameter("@Baoanchitiet", Baoanchitiet));
            Cmm.Parameters.Add(new OleDbParameter("@Chitietdiemtruong", Chitietdiemtruong));
            Cmm.Parameters.Add(new OleDbParameter("@Id", Id));

            ClsConnection.OleDbDAdpter(NamePrc, Cmm);
        }
        public void EditValueNot2(int Id, bool Nhanvienhosonam, bool Nhanvienhosogoc, bool
            Thutheothang, bool Thutheonam, bool Thutunguyen, bool Thucphamngay, bool NX_Thucpham, bool Baoan, bool Muaphieuan, bool Dulieunamhientai, bool Thucdonmonan)
        {

            string NamePrc = "update TblThamsodauvao "
        + "   SET  Nhanvienhosonam = " + Nhanvienhosonam.ToString()
        + "        ,Nhanvienhosogoc = " + Nhanvienhosogoc.ToString()
        + "        ,Thutheothang = " + Thutheothang.ToString()
        + "       ,Thutheonam = " + Thutheonam.ToString()
        + "       ,Thutunguyen = " + Thutunguyen.ToString()
        + "       ,Thucphamngay = " + Thucphamngay.ToString()
        + "       ,NX_Thucpham = " + NX_Thucpham.ToString()
        + "       ,Baoan = " + Baoan.ToString()
        + "       ,Muaphieuan = " + Muaphieuan.ToString()
        + "       ,Dulieunamhientai = " + Dulieunamhientai.ToString()
        + "       ,Thucdonmonan =" + Thucdonmonan.ToString()
        + "   where(Id = " + Id + ") ";
            OleDbCommand Cmm = new OleDbCommand();

            ClsConnection.OleDbDAdpter(NamePrc, Cmm);
        }
    }
}
